<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/26 0026
 * Time: 15:07
 */
namespace app\admin\model;
use think\Model;
class AuthAccess extends Model{
    function checkRule($uid='',$url){
        if(empty($uid)){
            $uid = 1;
        }
        $rules  =  db('auth_access')->alias('a')
             ->join('zhj_auth_group b','a.group_id=b.id')
             ->where('a.id',$uid)
             ->select();
        $ruleId = explode(',',$rules[0]['rules']);
        $map['id'] = ['in',$ruleId];
        $map['url']=$url;
        $res = db('rules')->where($map)->find();
        if($res or is_root()){
            return true;
        }else{
            return false;
        }
    }
}